package com.flea.hclv.controller;

import com.flea.hclv.model.entity.HProductAgencyOrder;
import com.flea.hclv.service.HProductAgencyOrderService;
import com.flea.hclv.util.ServerResponse;
import com.flea.system.bean.FleaPage;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 产品代客下单功能
 */
@Controller
@RequestMapping("/flea/hclv/productAgency")
public class HProductAgencyOrderController {
  @Autowired
  private HProductAgencyOrderService hProductAgencyOrderService;
  @RequestMapping("addAgency")
  @ResponseBody
  public ServerResponse<HProductAgencyOrder> addAgencyOrder(HttpServletRequest request){
    String model = request.getParameter("model");
    ServerResponse result = null;
    try {
      result =  hProductAgencyOrderService.addProduceAgency(model,request);
    } catch (Exception e) {
     ServerResponse.createByErrorMessage(e.getMessage());
    }
    return result;
  }
  @ResponseBody
  @RequestMapping("updateAgency")
  public ServerResponse<HProductAgencyOrder> updateAgencyOrderByAgencyId(HttpServletRequest request){
    String model = request.getParameter("model");
    ServerResponse result = null;
    try {
      result =  hProductAgencyOrderService.updateAgencyById(model,request);
    } catch (Exception e) {
      ServerResponse.createByErrorMessage(e.getMessage());
    }
    return result;
  }

  /**
   * 纯软删除
   * @param request
   * @return
   */
  @ResponseBody
  @RequestMapping("deteAgencyByIds")
  public ServerResponse<HProductAgencyOrder> deleteAgencyByIds(HttpServletRequest request){
    String model = request.getParameter("model");
    ServerResponse result = null;
    try {
      result =  hProductAgencyOrderService.deleteAgencyByIds(model,request);
    } catch (Exception e) {
      ServerResponse.createByErrorMessage(e.getMessage());
    }
    return result;
  }
  @ResponseBody
  @RequestMapping("findPaging")
  public ServerResponse<FleaPage<HProductAgencyOrder>> findPaging(HttpServletRequest request,FleaPage<HProductAgencyOrder> paging){

    ServerResponse<FleaPage<HProductAgencyOrder>> result = hProductAgencyOrderService.find4Paging(request,paging.getCurPage(),paging.getPageSize());

    return result;
  }


}
